Crate ht16k33

source ·
Expand description

HT16K33

ht16k33 is a driver for the Holtek HT16K33 RAM Mapping 16*8 LED Controller Driver with keyscan chip.

Currently, only the 28-pin SOP package type is supported.

Features

  • Uses the embedded-hal hardware abstraction.
  • Supports no_std for embedded devices.
  • Supports all 20/24/28-pin SOP package types.
  • Displays all 128 LEDs.
  • Reads keyscan.
  • Manages interrupts.
  • Manages slave devices.

Usage

NOTE: None is used for the Logger in these examples for convenience, in practice using an actual logger is preferred.

Linux-based platforms

Using the recommended linux-embedded-hal crate which implements the embedded-hal traits for Linux devices, including I2C.

extern crate linux_embedded_hal;
extern crate ht16k33;

use linux_embedded_hal::I2cdev;
use ht16k33::HT16K33;

// The I2C device address.
let address = 112u8;

// Create an I2C device.
let mut i2c = I2cdev::new("/path/to/i2c/device")?;
i2c.set_slave_address(address as u16)?;

let mut ht16k33 = HT16K33::new(i2c, address, None);

All platforms, using I2C simulation

Not all platforms have I2C support. The provided ht16k33::i2c_mock implements the embedded-hal traits for I2C.

extern crate ht16k33;
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;

// The I2C device address.
let address = 112u8;

// Create a mock I2C device.
let mut i2c = I2cMock::new(None);

let mut ht16k33 = HT16K33::new(i2c, address, None);

Re-exports

pub extern crate slog;

Modules

i2c_mock

Structs

Display dimming.
The LED display state.
RAM data for LED display.
Display RAM data address.
The HT16K33 state and configuration.
Represents the LED location.
System oscillator setup and control.

Enums

Errors encountered during validation.

Constants

The number of COMMONS available.
The number of ROWS available (28-pin).